import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'initialController.dart';

class InitialPage extends GetView<InitialController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: buildBody(),
      bottomNavigationBar: buildBottomNavigationBar(),
    );
  }

  Widget buildBody() {
    return GetBuilder<InitialController>(
      id: "g-body-pages",
      builder: ($) {
        return IndexedStack(
          index: $.bottomNavigationBarIndex.value,
          children: $.pages,
        );
      },
    );
  }

  Widget buildBottomNavigationBar() {
    return GetBuilder<InitialController>(
        id: "g-nav-bottoms",
        builder: ($) {
          return BottomNavigationBar(
            onTap: (index) => $.changeIndex(index),
            type: BottomNavigationBarType.fixed,
            currentIndex: $.bottomNavigationBarIndex.value,
            items: [
              BottomNavigationBarItem(
                icon: Icon(Icons.message),
                label: "initial-bottoms-home".tr,
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.people_outlined),
                label: "initial-bottoms-contacts".tr,
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.explore),
                label: "initial-bottoms-discover".tr,
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.perm_identity),
                label: "initial-bottoms-me".tr,
              ),
            ],
          );
        });
  }
}
